<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
if ( ! function_exists('customer'))
{
    
    function customer(){
        $CI = get_instance();
        
        $CI->load->model('Customers', '', true);
        return $CI->Customers->getListIndex();
    }

}

if ( ! function_exists('video'))
{
    function video(){
        $CI = get_instance();
        
        $CI->load->model('Videos', '', true);
        return $CI->Videos->getListIndex();
    }
}


if ( ! function_exists('get_product_categories_option'))
{
    function get_product_categories_option(){
        $CI = get_instance();
        
        $CI->load->model('Product_category', '', true);
        return $CI->Product_category->getOptions();
    }
}

/**
 * Load config
 * @author tien.nguyen
 */
if ( ! function_exists('config')){
    function config(){
        $CI = get_instance();
        
        $CI->load->model('Configs', '', true);
        $res = $CI->Configs->getList();
        foreach($res as $key => $item){
            $CI->session->set_userdata('CONFIG_'.$key, $item);
        }
    }
}
/*
 */
if ( ! function_exists('product_menu')){
    function product_menu(){
        $CI = get_instance();
        $CI->load->model('Products', '', true);
        $data['ProductSafe'] = $CI->Products->getListProduct(1);
        $data['ProductPerformance'] = $CI->Products->getListProduct(2);
        return $data;
    }
}

/**
 * Check is active
 */
if ( ! function_exists('isActiveMenu')){    
    function isActiveMenu($params){
        $CI = & get_instance();
        $segments = $CI->router->uri->segments;
        
        if(count($segments) == 0 && count($params) == 0){
            return true;
        }if(count($segments) == 0 || count($params) == 0){
            return false;
        }
        else{
            foreach($params as $key => $value){
                if(empty($segments[$key + 1])){                
                    return false;
                }
                
                if($segments[$key + 1] != $value && !empty($value)){  
                    //echo $segments[$key + 1] .'     '. $value; 
                    return false;
                }
            }
            return true;    
        }
        return false;
        /*
        if($menuName == $CI->router->class){
            return true;
        }else{
            return false;
        }*/
    }
}

?>